
#ifndef FUNCTIONS_H
#define FUNCTIONS_H

#include "SDL/SDL.h"
#include "SDL/SDL_rotozoom.h"
#include "SDL/SDL_ttf.h"
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

#include <math.h>

#include "Structs.h"
#include "ConfigFile.h"

using namespace std;

int CloseFont(TTF_Font *font);

int BlitToSurfacePosition(Point Position, SDL_Surface *surface, SDL_Surface *Image);

template <class unknownt, class T>
unknownt convertTo(T inVar)
{
     stringstream temp;
     unknownt unknownVar;
     temp << inVar;
     temp >> unknownVar;
     return unknownVar;
}

SDL_Color GetSDLColor(int r, int g, int b);

template <class m1, class m2>
bool KeyInMap(map<m1, m2> m, m1 key)
{
    if (m.find(key) == m.end())
    {
        return false;
    }

    return true;
}

template <class m1>
bool KeyInMap(map<m1, m1> m, m1 key)
{
    if (m.find(key) == m.end())
    {
        return false;
    }

    return true;
}

template <class Tm>
void FillMatrix(boost::numeric::ublas::matrix<Tm> &m, Tm v)
{
    for (unsigned int x = 0; x < m.size1(); ++x)
    {
        for (unsigned int y = 0; y < m.size2(); ++y)
        {
            m(x, y) = v;
        }
    }
}

void SetSurfaceContrast(const int& iValue, SDL_Surface *surface);

Point GetWindowSize();

void OutlineText(SDL_Surface *surface, SDL_Color OutlineColour);

PixelData GetPixelData(Point Position, SDL_Surface *surface);
void SetPixelData(Point Position, SDL_Surface *surface, PixelData Data);

void OutlineText(SDL_Surface *surface, SDL_Color OutlineColour, SDL_Color TextColour);

SDL_Surface* OptimiseSurface(SDL_Surface *surface);
SDL_Surface* OptimiseAlphaSurface(SDL_Surface *surface);

#endif
